package com.xmu.prcs.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Index;
/**
 * 上传的植物表
 * @author frequent
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "uploadplant", uniqueConstraints = @UniqueConstraint(columnNames = "plantname"))
@org.hibernate.annotations.Table(appliesTo = "uploadplant",
        indexes = {@Index(name = "idxUUT", columnNames = {"uploadtime"})})
public class UploadPlant implements Serializable {

	private Integer idUploadPlant;
	private String plantName; //植物名
	private Date uploadTime; //上传时间
	private Plant plant;//植物
	
	public UploadPlant(){
		
	}
	
	public UploadPlant(String plantName, Date uploadTime){
		this.plantName = plantName;
		this.uploadTime = uploadTime;
	}

	@Id
	@GeneratedValue
	@Column(name = "iduploadplant", unique = true, nullable = true)
	public Integer getIdUploadPlant() {
		return idUploadPlant;
	}

	public void setIdUploadPlant(Integer idUploadPlant) {
		this.idUploadPlant = idUploadPlant;
	}

	@Column(name = "plantname", length = 20)
	public String getPlantName() {
		return plantName;
	}

	public void setPlantName(String plantName) {
		this.plantName = plantName;
	}

	@Column(name = "uploadtime")
	public Date getUploadTime() {
		return uploadTime;
	}

	public void setUploadTime(Date uploadTime) {
		this.uploadTime = uploadTime;
	}

	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idplant", nullable = true)
	public Plant getPlant() {
		return plant;
	}

	public void setPlant(Plant plant) {
		this.plant = plant;
	}
	
}
